<?php

/**
 * Access Token 有效期：测试 1天  普通 7天
 */
namespace frontend\controllers;

use bc\controller\FrontController;
use bc\util\Util;

class WeiboController extends FrontController
{
	
	const APPKEY = '724579473';
	
	/**
	 * OAuth2的authorize接口 
	 * @var string
	 */
	const AUTHORIZE = 'https://api.weibo.com/oauth2/authorize?';
	
	
	public function actionIndex()
	{
		$weibo_url = self::AUTHORIZE . 'client_id=' . self::APPKEY . '&redirect_uri=http://test.wx.zhishimama.com/weibo/code&response_type=code';
		$view['weibo_url'] = $weibo_url;
		
		return $this->render('index', $view);
	}
	
	
	public function actionTest()
	{
		
		$params['client_id'] = self::APPKEY;
		$params['redirect_uri'] = 'http://test.wx.zhishimama.com/weibo/code';
		
		Util::httpGet(self::AUTHORIZE, $params);
	}
	
	public function actionCode()
	{
		echo $this->get('code');
	}
}

